package com.ease.lang
{
   /* http://scottbilas.com/blog/ultimate-as3-fake-enums/ */
   public final class NetError extends Enum
   {
      // static ctor
      { initEnum(NetError); } 
      
      // Constants      
      public static const None            :NetError = new NetError(false, "no error");
      public static const CantConnect     :NetError = new NetError(false, "can't connect to the server, must be down?");
      public static const VersionMismatch :NetError = new NetError(true,  "protocol versions different");
      public static const Unknown         :NetError = new NetError(true,  "unexpected error type");
      
      
      private var _isFatal     :Boolean;
      private var _description :String;
      
      /*private*/ function NetError(i_isFatal :Boolean, i_description :String) { 
         _isFatal = i_isFatal; 
         _description = i_description; 
      }
      
      // Constant attributes      
      public function get isFatal()     :Boolean  { return _isFatal; }
      public function get description() :String   { return _description; }        
      
      // Constant query      
      public static function getEnumConstants() :Array { 
         return Enum.getEnumConstants(NetError); 
      }
      
      public static function get(i_constantName :String, i_caseSensitive :Boolean = false) :NetError {
            return NetError(Enum.get(NetError, i_constantName, i_caseSensitive)); 
      }
      /* test */
//      for each (var netError :NetError in NetError.GetConstants())
//      {
//         trace(
//            netError.index + ": " + netError.name +
//            " (" + netError.Description + ") " +
//            (netError.isFatal ? "[FATAL]" : ""));
//      }

      
   }

}